package com.michael.study.jetpack.module.work

import androidx.arch.core.util.Function
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.michael.study.jetpack.bean.User

/**
 * Description:
 *
 * Created by liuguoquan on 2020/6/29 10:43.
 */
class MainViewModel() : ViewModel() {

    private val refreshLiveData = MutableLiveData<Any?>()

    val user:LiveData<User> = Transformations.switchMap(refreshLiveData, Function {
        Repository.refresh()
    })

    fun refresh() {
        refreshLiveData.value = refreshLiveData.value
    }
}